<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>解析html，生成请求方法</title>
    <link
      rel="stylesheet"
      href="../node_modules/bootstrap/dist/css/bootstrap.min.css"
    />
  </head>
  <style>
    .btn-default {
      background: bisque;
      font-size: 20px;
    }
  </style>
  <body>
    <div class="container">
      <div class="page-header"></div>
    </div>
    <div class="container">
      <form action="form" method="post" enctype="multipart/form-data">
        <div class="form-group">
          <br />
          <br />

          将ApiFox接口页面下载至本地，后选择
          <br />

          <br />
          <input type="file" placeholder="选择文件" name="html" required />
          <br />
          <br />

          <input
            type="text"
            id="username"
            class="form-control"
            name="name"
            placeholder="返回结果类名默认bool，其他如: List<bool>, XXXBean, List<XXXBean>等"
            minlength="2"
          />
        </div>
        <br />

        <button type="submit" class="btn btn-default">生成</button>
      </form>
      <br />
      <br />

      <div
        id="copyContent"
        style="white-space: pre-line; background-color: aliceblue"
      >
        {{res }}
      </div>
      <div
        id="copyViewModelContent"
        style="
          white-space: pre-line;
          background-color: aliceblue;
          height: 10px;
          overflow: hidden;
        "
      >
        {{viewModelFuncStr }}
      </div>
      <div
        id="pageLoad"
        style="
          white-space: pre-line;
          background-color: aliceblue;
          height: 10px;
          overflow: hidden;
        "
      >
        {{pageLoad }}
      </div>
      <br />

      <button type="button" class="btn btn-default" onclick="copy()">
        复制结果
      </button>
      <button
        type="button"
        class="btn btn-default"
        onclick="copyViewModel(false)"
      >
        复制ViewModel结果
      </button>
      <button
        type="button"
        class="btn btn-default"
        onclick="copyViewModel(true)"
      >
        复制ViewModel结果带分页
      </button>
      <br />
      <br />

      <textarea id="input"></textarea>
      <textarea id="inputViewModel"></textarea>

      <script>
        function copy() {
          var text = document.getElementById("copyContent").innerText;
          var input = document.getElementById("input");
          input.textContent = text; // 修改文本框的内容
          input.select(); // 选中文本
          document.execCommand("copy"); // 执行浏览器复制命令
        }
        function copyViewModel(isPage) {
          var text = document.getElementById("copyViewModelContent").innerText;
          if (isPage) {
            text += "\n" + document.getElementById("pageLoad").innerText;
          }
          var input = document.getElementById("inputViewModel");
          input.textContent = text; // 修改文本框的内容
          input.select(); // 选中文本
          document.execCommand("copy"); // 执行浏览器复制命令
        }
      </script>
    </div>
  </body>
</html>
